package com.tarena.vehicle.management.converter;

import com.tarena.vehicle.management.pojo.entity.Vehicle;
import com.tarena.vehicle.management.pojo.param.VehicleAddNewParam;
import com.tarena.vehicle.management.pojo.param.VehicleUpdateParam;
import com.tarena.vehicle.management.pojo.query.VehicleQuery;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

@Component
public class VehicleConverter {

    public Vehicle param2po(VehicleAddNewParam vehicleAddNewParam) {
        Vehicle vehicle = new Vehicle();
        BeanUtils.copyProperties(vehicleAddNewParam, vehicle);
        vehicle=setUserMessage(vehicle);
        return vehicle;
    }
    public Vehicle param2po(VehicleUpdateParam vehicleUpdateParam) {
        Vehicle vehicle = new Vehicle();
        BeanUtils.copyProperties(vehicleUpdateParam, vehicle);
        vehicle=setUserMessage(vehicle);
        return vehicle;
    }

    public Vehicle query2po(VehicleQuery vehicleQuery) {
        Vehicle vehicle = new Vehicle();
        BeanUtils.copyProperties(vehicleQuery, vehicle);
        return vehicle;
    }

    public Vehicle setUserMessage(Vehicle vehicle){
        vehicle.setUid(1);
        vehicle.setOrgid(1);
        vehicle.setCompanyCode("JSDTN2210");
        return vehicle;
    }
}
